package com.chaoyong.higo.base;



import com.chaoyong.higo.R;
import com.chaoyong.higo.utils.ViewHolder;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class StringAdapter extends BaseAdapter{
	private Context context;
	private String[] mList;
	private int click =-1; 
	public StringAdapter(Context mContext,String[] list){
		context=mContext;
		mList=list;
	}
	@Override
	public int getCount() {
		if (mList != null)
			return mList.length;
		else
			return 0;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}
	
	public void setList(String[] list){
		mList=list;
		notifyDataSetChanged();
	}
	
	public void setClick(int click){
		this.click=click;
		notifyDataSetChanged();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=View.inflate(context, R.layout.textview_keep_left, null);
		}
		TextView content=ViewHolder.get(convertView, R.id.textview_left);
		content.setText(mList[position]);
		if(click==position){
			content.setBackgroundResource(R.color.onclick_background_pressed);
		}else
			content.setBackgroundResource(R.drawable.onclick_background);
		return convertView;
	}

}
